﻿using Application.ProductTypeService;
using AutoMapper;
using Domain.Entity;
using Domain.Entity.bs;
using Domain.Entity.zct;
using Domain.IRepository;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Application.PositionService
{
    public class PositionService : IPositionService
    {
        private readonly IPositionRepository positionRepository;
        private readonly IMapper mapper;
        public PositionService(IPositionRepository positionRepository, IMapper mapper)
        {
            this.positionRepository = positionRepository;
            this.mapper = mapper;
        }

        //添加
        public async Task<int> GetAdd(AddPositionDto addPositionDto)
        {
            Position position = mapper.Map<Position>(addPositionDto);
            return await positionRepository.GetAdd(position);
        }

        //全部查
        public async Task<List<Position>> GetAll()
        {
            return await positionRepository.GetAll();
        }

        //条件查
        public async Task<FenYe<Position>> GetCondition(FenYe<Position> fenYe, string? Position_code, string? Position_name, int? Position_status)
        {
            return await positionRepository.GetCondition(fenYe, Position_code, Position_name, Position_status);
        }

        //停用
        public async Task<int> GetDeactivated(int id)
        {
            return await positionRepository.GetDeactivated(id);
        }

        //删除
        public async Task<int> GetDelete(int id)
        {
            return await positionRepository.GetDelete(id);
        }

        //编辑
        public async Task<int> GetEdit(UpdatePositionDto updatePositionDto)
        {
            Position position = mapper.Map<Position>(updatePositionDto);
            return await positionRepository.GetEdit(position);
        }

        //启用
        public async Task<int> GetEnable(int id)
        {
            return await positionRepository.GetEnable(id);
        }

        //id查询
        public async Task<Position> GetID(int id)
        {
            return await positionRepository.GetID(id);
        }
    }
}
